package pers.vic.dubbo.provider.controller;

import org.apache.dubbo.common.constants.CommonConstants;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import pers.vic.boot.util.CommonUtils;
import pers.vic.dubbo.common.constant.DubboConstant;
import pers.vic.dubbo.common.model.SessionInfo;
import pers.vic.dubbo.provider.service.ProviderTestService;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.Date;

/**
 * 描述:
 * @author Vic.xu
 * @date 2022-01-04 13:38
 */
@RestController
@RequestMapping("/provider")
public class ProviderTestController {

    @Resource
    private ProviderTestService providerTestservice;

    @RequestMapping("/api")
    public Object api(int num){
        return providerTestservice.justAdd(num, 11);
    }


    @RequestMapping("/session")
    public Object createSession(HttpSession session){
        SessionInfo info = new SessionInfo();
        info.setAge(28);
        info.setId(CommonUtils.randomUuid());
        info.setUsername("zhangsan");
        info.setBirthday(new Date());
        session.setAttribute(DubboConstant.SESSION_INFO, info);
        return info;
    }
}
